<script>
	$(function(){
		EBCMS.{$namespace}.imports = function imports(queryParams){
			$.ajax({
				url: '{:U('imports')}',
				type: 'POST',
				dataType: 'JSON',
				data: queryParams,
				success:function(data){
					if (data.status) {
						if (data.info.start == -1) {
							$('#{$namespace}_imports_'+Number(data.info.part-1)).html('100 %');
							EBCMS.{$namespace}.refresh();
							EBCMS.{$namespace}table.refresh();
							EBCMS.MSG.alert('还原成功！');
						}else if(data.info.initend == 1){
							$('#{$namespace}_imports_init_0').html('完成！');
							setTimeout(function() {
								$('#{$namespace}_imports_init_1').html('完成！');
								EBCMS.{$namespace}.imports(data.info);
							}, 100);
						}else{
							$('#{$namespace}_imports_'+data.info.part).html(data.info.rate+' %');
							if (data.info.start==0) {
								$('#{$namespace}_imports_'+Number(data.info.part-1)).html('100 %');
							};
							EBCMS.{$namespace}.imports(data.info);
						};
					}else{
						EBCMS.MSG.alert(data.info);
					};
				},
				error:function(XMLHttpRequest, textStatus, errorThrown){
					EBCMS.MSG.alert('数据请求失败：'+textStatus+' '+errorThrown+'<br />请求地址:'+url+'<br />AJAX请求信息：'+JSON.stringify(this)+'<br /><span style="color:red">如无法解决该问题，请联系EBCMS官方获取帮助</span>');
				}
			});
		}
	});
</script>
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	<h4 class="modal-title">数据还原</h4>
</div>
<div class="modal-body">
	<h5 class="text-warning"><b><span class="glyphicon glyphicon-phone-alt"></span> 还原初始化</b></h5>
	<ul class="list-group">
		<li class="list-group-item">
			<span class="badge" id="{$namespace}_imports_init_0">?</span>
			数据完整性检测
		</li>
		<li class="list-group-item">
			<span class="badge" id="{$namespace}_imports_init_1">?</span>
			准备数据
		</li>
	</ul>
	<h5 class="text-warning"><b><span class="glyphicon glyphicon-phone-alt"></span> 还原初始化</b></h5>
	<ul class="list-group">
		<foreach name='backup_list' item='table'>
			<li class="list-group-item">
				<span class="badge" id="{$namespace}_imports_{$key}">...</span>
				{$table}
			</li>
		</foreach>
	</ul>
</div>
<div class="modal-footer">
	<button type="button" class="btn btn-success" onclick="EBCMS.{$namespace}.imports({init:1,filetime:'{:I('filetime')}'});">开始</button>
	<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>